<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="common.jsp" %>
<html>
<head>
    <title>Title</title>
    <script>
        window.onload = function () {
            layui.use('upload', function () {
                var upload = layui.upload;

                //执行实例
                var uploadInst = upload.render({
                    elem: '#test1' //绑定元素
                    , url: '/upload' //上传接口
                    , method: 'post'
                    , accept: 'file'
                    , done: function (res) {
                        //上传完毕回调
                        layer.alert("上传成功了哟~")
                    }
                    , error: function () {
                        //请求异常回调
                        layer.alert("上传失败了哇~")
                    }
                });
            });
        }
    </script>
</head>
<body>
<div>
    <button type="button" class="layui-btn" id="test1">
        <i class="layui-icon">&#xe67c;</i>上传图片
    </button>
</div>
</body>
</html>
